<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [2,3,5,6,66,6,1,2,2,3];

        let f = function findall(x,arr){
           let ans  = [];
           let index = 0;
           for(let i = 0;i < arr.length;++i){
            if(arr[i] == x)
                ans[index++] = i;
           }
           return ans;
        }
        function indexOf(x,arr){
            let count = 0;
            for(let i = 0;i < arr.length;++i)
                if(arr[i] == x)
                ++count;
            return count;
        }
        let index  = f(2,arr);
        let count = indexOf(2,arr);
        document.write('索引下标：'+index+'<br>');
        document.write('出现次数：'+count+'<br>');
    </script>
</body>
</html>